package com.cloudwise.monitoring_system.controller;

import com.cloudwise.monitoring_system.service.RedisService;
import com.cloudwise.monitoring_system.util.Result;
import com.cloudwise.monitoring_system.util.ReturnStatus;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author Reisen
 * @description:
 * @date 2021/6/4 16:56
 */
@Controller
@RequestMapping("redisController")
@ApiOperation("redis展示最新一条监控数据")
public class RedisController {
    @Resource
    private RedisService redisService;

    /**
     * 从redis中取出来最新的一条数据
     * @return
     */
    @RequestMapping("get")
    @ResponseBody
    @ApiOperation("获取最新监控数据")
    public Result getRedis(){
        return new Result(ReturnStatus.SUCCESS.getCode(), ReturnStatus.SUCCESS.getMessage(),
                0,redisService.getLatestRedisData());
    }

}
